package com.lll.simple.rpc.protocol.serialization;

import java.io.IOException;

/**
 * @Author: liull
 * @Description: 序列化接口
 * @Date: Created in 11:27 2021/2/4
 * @Modified By:
 */
public interface RpcSerialization {

    /**
     * 序列化
     * 
     * @param obj 要序列化的对象
     * @param <T>
     * @return
     * @throws IOException
     */
    <T> byte[] serialize(T obj) throws IOException;

    /**
     * 反序列化
     * 
     * @param data 字节数组
     * @param clazz 目标类型
     * @param <T>
     * @return
     */
    <T> T deserialize(byte[] data, Class<T> clazz) throws IOException;
}
